# /**
# * Copyright (c) 2022 Beijing Jiaotong University
# * photlab is licensed under [Open Source License].
# * You can use this software according to the terms and conditions of the [Open Source License].
# *
# * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
# *
# * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# *
# * See the [Open Source License] for more details.
# */
# /**
# * Author: Shihao Xie
# * Created: Jul. 5, 2022
# * Supported by: National Key Research and Development Program of China
# */


# thrift --gen py ./interface/graph_service.thrift
# interface count = 46
namespace py phot_server.rpc.graph_service
namespace js photlab.graph_service

include "graph_data_type.thrift"
include "common_data_type.thrift"

# The domain of graph service is transport the information about graph
service Graph{

# GRAPH INTERFACES
    graph_data_type.PhotGraph open_graph(1:string graph_path) throws (1:common_data_type.PhotError error)

    void save_graph(1:string graph_id) throws (1:common_data_type.PhotError error)

    void close_all_opened_graph(1:bool save) throws (1:common_data_type.PhotError error)

    void save_graph_as(1:string graph_path, 2:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.PhotGraph new_graph(1:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.PhotGraph get_graph(1:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.RenderGraph get_render_graph(1:string graph_id) throws (1:common_data_type.PhotError error)

    void alter_graph_attribute(1:string graph_id, 2:string attribute_name, 3:string attribute_value) throws (1:common_data_type.PhotError error)

    void close_graph(1:string graph_id, 2:bool ignore_change = false) throws (1:common_data_type.PhotError error)

    void rename_graph(1:string graph_id, 2:string new_name) throws (1:common_data_type.PhotError error)

    map<string, string> get_opened_graph_list() throws (1:common_data_type.PhotError error)

# GLOBAL PARAMETER INTERFACES
    map<string, list<graph_data_type.PhotParameter>> get_graph_parameters(1:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.PhotParameter get_graph_parameter(1:string graph_id, 2:string parameter_name)
                                                      throws (1:common_data_type.PhotError error)

    void alter_graph_parameter(1:string graph_id, 2:string graph_parameter_name, 3:graph_data_type.PhotParameter graph_parameter)
                               throws (1:common_data_type.PhotError error)

    void alter_graph_parameters(1:string graph_id, 2:list<graph_data_type.PhotParameter> graph_parameters)
                                throws (1:common_data_type.PhotError error)

    graph_data_type.PhotParameter add_graph_parameter(1:string graph_id, 2:graph_data_type.PhotParameter graph_parameter)
                             throws (1:common_data_type.PhotError error)

    void delete_graph_parameter(1:string graph_id, 2:string graph_parameter_name)
                                throws (1:common_data_type.PhotError error)

# COMPONENT INTERFACES
    graph_data_type.PhotComponent get_component(1:string graph_id, 2:i32 component_id)
                                                throws (1:common_data_type.PhotError error)

    list<graph_data_type.PhotComponent> get_components(1:string graph_id)
                                                       throws (1:common_data_type.PhotError error)

    graph_data_type.PhotComponent add_component(1:string graph_id,2:graph_data_type.PhotComponent component)
                       throws (1:common_data_type.PhotError error)

    graph_data_type.PhotComponent add_component_from_library(1:string graph_id, 2:string component_path, 4:graph_data_type.RenderRect rect)
                                    throws (1:common_data_type.PhotError error)

    void delete_component(1:string graph_id, 2:i32 component_id, 3:bool cascade_delete = false) throws (1:common_data_type.PhotError error)

    void alter_component(1:string graph_id, 2:graph_data_type.PhotComponent component) throws (1:common_data_type.PhotError error)

# RENDER NODE INTERFACE
    graph_data_type.RenderGraphNode get_render_node(1:string graph_id, 2:i32 component_id)
                                                   throws (1:common_data_type.PhotError error)

    list<graph_data_type.RenderGraphNode> get_render_nodes(1:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.RenderGraphNode add_render_node(1:string graph_id, 2:graph_data_type.RenderGraphNode node) throws (1:common_data_type.PhotError error)

    void delete_render_node(1:string graph_id, 2:i32 component_id, 3:bool cascade_delete = false) throws (1:common_data_type.PhotError error)

    void set_render_node_rect(1:string graph_id, 2:i32 component_id, 3:graph_data_type.RenderRect rect) throws (1:common_data_type.PhotError error)

    void render_node_move_to(1:string graph_id, 2:i32 component_id, 3:i32 x, 4:i32 y) throws (1:common_data_type.PhotError error)

    void alter_render_node(1:string graph_id, 2:graph_data_type.RenderGraphNode node)
                           throws (1:common_data_type.PhotError error)

# LINK INTERFACE
    graph_data_type.PhotGraphLink add_link(1:string graph_id, 2:graph_data_type.PhotGraphLink link) throws (1:common_data_type.PhotError error)

    list<graph_data_type.PhotGraphLink> get_links(1:string graph_id) throws (1:common_data_type.PhotError error)

    graph_data_type.PhotGraphLink get_link(1:string graph_id, 2:i32 link_id) throws (1:common_data_type.PhotError error)

    void delete_link(1:string graph_id, 2:i32 link_id, 3:bool delete_render=false) throws (1:common_data_type.PhotError error)

    void alter_link(1:string graph_id, 2:graph_data_type.PhotGraphLink link)
                    throws (1:common_data_type.PhotError error)

# RENDER ROUTE INTERFACE
    graph_data_type.RenderRoute add_render_route(1:string graph_id, 2:graph_data_type.RenderRoute route) throws (1:common_data_type.PhotError error)

    graph_data_type.RenderRoute get_render_route(1:string graph_id,2:i32 link_id) throws (1:common_data_type.PhotError error)

    void delete_render_route(1:string graph_id, 2:i32 link_id, 3:bool delete_model=false) throws (1:common_data_type.PhotError error)

    void set_render_route_path(1:string graph_id,2:i32 link_id,3:list<graph_data_type.RenderWayPoint> points)
                        throws (1:common_data_type.PhotError error)

# TEXT AREA INTERFACE
    graph_data_type.RenderTextArea add_text_area(1:string graph_id, 2:graph_data_type.RenderTextArea text_area) throws (1:common_data_type.PhotError error)

    graph_data_type.RenderTextArea get_text_area(1:string graph_id, 2:i32 text_id)throws (1:common_data_type.PhotError error)

    void delete_text_area(1:string graph_id, 2:i32 text_id) throws (1:common_data_type.PhotError error)

    void alter_text_area(1:string graph_id, 2:graph_data_type.RenderTextArea text_area)
                       throws (1:common_data_type.PhotError error)

    void set_text(1:string graph_id, 2:i32 text_id, 3:string text) throws (1:common_data_type.PhotError error)

    void set_text_area_rect(1:string graph_id, 2:i32 text_id, 3:graph_data_type.RenderRect rect) throws (1:common_data_type.PhotError error)

# REDO AND UNDO INTERFACE
    void revocation(1:string graph_id) throws (1:common_data_type.PhotError error)

    void recover(1:string graph_id) throws (1:common_data_type.PhotError error)
}